"""
This is a basic zone object.
"""
import entity
import bitarray
from cPickle import dump, load

class zoneAcl(object):
    def __init__(self, uid, perms):
        self.id = uid
        self.perms = perms

class zone(object):
    rooms = []
    acl = []
    name = ""

    def serialize(self):
        if not self.name:
            return False
        output = open("data/zones/%s.zon" %(self.name), "w")
        dump(self, output)
        output.close()

    @staticmethod
    def deserialize(path):
        """
        Called with the path of the file to deserialize into a zone.
        """
        if not path.endswith(".zon"):
            return False
        input = open(path, "r")
        obj = load(input)
        input.close()
        return obj
